package org.example.sword2offer.medium;

/**
 * @author: lynn
 * @Descript:    “student. a am I”  “I am a student.”
 * Question 1
 * @date: 2021/3/5 1:06
 * @version: 1.0
 */
public class ReversWords {

    public static void main(String[] args) {
        String words= "student. a am I";
        String[] wordsArray=words.split(" ");
        StringBuilder sb=new StringBuilder();
        for (int i = wordsArray.length; i >0 ; i--) {
            if (i==1){
                sb.append(wordsArray[i-1]);
            }else {
                sb.append(wordsArray[i-1]+" ");
            }
        }
        System.out.println(sb.toString());
    }
}
